
set(reference_file "${RunCMake_TEST_BINARY_DIR}/WARNING_AS_ERROR.txt")
if (NOT EXISTS "${reference_file}")
  set (RunCMake_TEST_FAILED "${reference_file}: Reference file not found.")
  return()
endif()
file(READ "${reference_file}" WarnErrorFlags)

if(NOT WarnErrorFlags STREQUAL "UNDEFINED")
  if(WARNING_AS_ERROR)
    if(NOT actual_stdout MATCHES "${WarnErrorFlags}")
      set (RunCMake_TEST_FAILED "LINK_WARNING_AS_ERROR: flag is missing.")
    endif()
  else()
    if(actual_stdout MATCHES "${WarnErrorFlags}")
      set (RunCMake_TEST_FAILED "LINK_WARNING_AS_ERROR: flag unexpectedly present: '${WarnErrorFlags}'")
    endif()
  endif()
endif()
